<template>
  <div >
   哈喽兔子
   {{$store.state.user.profile.nickname}}
  </div>
  <button @click="btn" >点击</button>
</template>

<script>
import { useStore } from 'vuex'

export default {
  name: 'Home',
  setup () {
    // Vue2.x 写法，通过 this 获取
    // this.$store.state.user.profile.nickname
    // 🔔 Vue3.x 写法，通过 useStore() 获取
    const store = useStore()
    console.log(store.state.user.profile.nickname)

    const btn = () => {
      store.commit('user/setUserId', 304)
    }
    return { btn }
  }
}
</script>

<style lang="less" scoped>
button{
  background-color: @priceColor;
}
</style>
